package com.hit.aircraftwar.aircraft;

import com.hit.aircraftwar.basic.AbstractFlyingObject;
import com.hit.aircraftwar.basic.BombAffectedObject;
import com.hit.aircraftwar.bullet.AbstractBullet;
import com.hit.aircraftwar.strategy.ShootStrategy;

import java.util.List;

/**
 * 所有种类飞机的抽象父类：
 * 敌机（BOSS, ELITE, MOB），英雄飞机
 *
 * @author hitsz
 */
public abstract class AbstractAircraft extends AbstractFlyingObject implements BombAffectedObject {
    /**
     * 生命值
     */
    protected int direction;
    protected int power;
    protected int shootNum;
    protected int maxHp;
    protected int hp;
    protected ShootStrategy shootStrategy;

    public AbstractAircraft(int locationX, int locationY, int speedX, int speedY, int hp, ShootStrategy shootStrategy, int direction, int power, int shootNum) {
        super(locationX, locationY, speedX, speedY);
        this.hp = hp;
        this.maxHp = hp;
        this.shootStrategy = shootStrategy;
        this.direction = direction;
        this.power = power;
        this.shootNum = shootNum;
    }

    public void decreaseHp(int decrease){
        hp -= decrease;
        if(hp <= 0){
            hp = 0;
            vanish();
        }
        else if(hp > maxHp){
            hp = maxHp;
        }
    }

    public int getHp() {
        return hp;
    }


    /**
     * 飞机射击方法，可射击对象必须实现
     * @return
     *  可射击对象需实现，返回子弹
     *  非可射击对象空实现，返回null
     */
    public abstract List<AbstractBullet> shoot(AbstractAircraft abstractAircraft);

    public int getDirection() {
        return direction;
    }

    public int getShootNum() {
        return shootNum;
    }

    public int getPower() {
        return power;
    }

    public void setShootStrategy (ShootStrategy shootStrategy) {
        this.shootStrategy = shootStrategy;
    }
}


